/**
 * @see https://umijs.org/zh-CN/plugins/plugin-access
 * */
export default function access(initialState: { currentUser?: API.CurrentUser | undefined }) {
    const { currentUser } = initialState || {};
    return {
        canAdmin: currentUser && currentUser.access === 'admin',
        canSuperAdmin: currentUser && currentUser.access === 'superAdmin',
        canReadXxx: currentUser && currentUser.access === 'admin',
        canDeleteXxx: (item: { xxx: any }) => {
            // @ts-ignore
            return item.xxx === currentUser.xxx;
        },
    };
}
